<!-- 弹modal框, 新增用例 -->
<div class="modal fade" id="addTCModal" tabindex="-1" role="dialog" aria-labelledby="addTCModalLabel" aria-hidden="true" style="height:100%;overflow-y: scroll;">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="addTCModalLabel">新增用例</h4>
      </div>
      <div class="modal-body">
        <div id="tc_template" uniqid="" class="form-group" >
          <div class="form-group">
            <label class="control-label" style="text-align:right">选择接口</label>
            <select id="select_tc_coll_apiName" name="tc_apiName" class="form-control" onchange="changeAPI()"/>
            <!--<option value="">text</option>-->
            </select>
            <button id="populate_case" type="button" class="btn btn-info" style="display: none">确定</button>
          </div>
          <div class="form-group">
            <label class="control-label" style="text-align:right">用例名</label>
            <input name="tc_title" class="form-control" required="required" />
          </div>
          <div class="form-group">
            <label class="control-label" style="text-align:right">用例描述</label>
            <input name="tc_desc" class="form-control" required="required" />
          </div>
          <div class="form-group" >
            <label class="control-label" style="text-align:right">前置脚本</label>
            <textarea name="tc_prescript" class="form-control" rows="5" required="required"/>
          </div>
          <div class="form-group" >
            <label class="control-label" style="text-align:right">后置脚本</label>
            <textarea name="tc_testscript" class="form-control" rows="5" required="required"/>
          </div>
          <div class="form-group">
            <label class="control-label">请求URL</label>
            <input name="tc_url" class="form-control" required="required" />
          </div>
          <div class="form-group">
            <label class="control-label">请求content-type</label>
            <input name="tc_dataType" class="form-control" required="required" />
            <select class="form-control" name="tc_dataType" style="display: none">
              <option value="application/json">application/json</option>
              <option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</option>
              <option value="application/application/octet-stream">application/application/octet-stream</option>
              <option value="text/html">text/html</option>
              <option value="text/plain">text/plain</option>
              <option value="text/xml">text/xml</option>
              <option value="image/gif">image/gif</option>
              <option value="image/jpeg">image/jpeg</option>
              <option value="image/png">image/png</option>
            </select>
          </div>
          <div class="form-group">
            <label class="control-label">请求method</label>
            <input name="tc_method" class="form-control" required="required" />
            <select class="form-control" name="tc_method" style="display:none">
              <option value="POST" selected="selected">POST</option>
              <option value="GET">GET</option>
            </select>
          </div>
          <div class="form-group">
            <label class="control-label">是否废弃</label>
            <input name="tc_disabled" class="form-control" required="required" />
            <select class="col-3 form-control" name="tc_disabled" style="display:none">
              <option value="false">false</option>
              <option value="true">true</option>
            </select>
            <label class="control-label">开发者</label>
            <input name="tc_dev" class="form-control" required="required" />
            <select class="col-3 form-control" name="tc_dev" style="display: none" >
              <option value="赵聃">赵聃</option>
              <option value="李德洪">李德洪</option>
              <option value="周欢">周欢</option>
            </select>
          </div>
          <div class="form-group">
            <label class="control-label">请求头header</label>
            <div id="jsoneditor_header_" style="width: auto; height: auto;"></div>
          </div>
          <div class="form-group">
            <label class="control-label">请求参数</label>
            <div id="jsoneditor_queryParams_" style="width: auto; height: auto;"></div>
          </div>
          <div class="form-group">
            <label class="control-label">返回结果Response</label>
            <div id="jsoneditor_response_" style="width: auto; height: auto;"></div>
          </div>
          <!--</li>-->
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" data-backdrop="false" id="btn_add_tc" ></span>保存</button>
      </div>
    </div>
  </div>
</div>

<!-- 弹modal框, 编辑用例 -->
<div class="modal fade" id="editTCModal" tabindex="-1" role="dialog" aria-labelledby="editTCModalLabel" aria-hidden="true" style="height:100%;overflow-y: scroll;">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="editTCModalLabel">修改用例</h4>
      </div>
      <div class="modal-body">
        <div id="tc_template2" class="form-group" >
          <div class="form-group">
            <label class="control-label" style="text-align:right">用例名</label>
            <input name="tc_title" class="form-control" required="required" />
          </div>
          <div class="form-group">
            <label class="control-label" style="text-align:right">用例描述</label>
            <input name="tc_desc" class="form-control" required="required" />
          </div>
          <div class="form-group" >
            <label class="control-label" style="text-align:right">前置脚本</label>
            <textarea name="tc_prescript" class="form-control" rows="5" required="required"/>
          </div>
          <div class="form-group" >
            <label class="control-label" style="text-align:right">后置脚本</label>
            <textarea name="tc_testscript" class="form-control" rows="5" required="required"/>
          </div>
          <div class="form-group">
            <label class="control-label">请求URL</label>
            <input name="tc_url" class="form-control" required="required" disabled="disabled" />
          </div>
          <div class="form-group">
            <label class="control-label">请求content-type</label>
            <select class="form-control" name="tc_dataType" disabled="disabled">
              <option value="application/json" style=" ">application/json</option>
              <option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</option>
              <option value="application/application/octet-stream">application/application/octet-stream</option>
              <option value="text/html">text/html</option>
              <option value="text/plain">text/plain</option>
              <option value="text/xml">text/xml</option>
              <option value="image/gif">image/gif</option>
              <option value="image/jpeg">image/jpeg</option>
              <option value="image/png">image/png</option>
            </select>
          </div>
          <div class="form-group">
            <label class="control-label">请求method</label>
            <select class="form-control" name="tc_method" disabled="disabled">
              <option value="POST" selected="selected">POST</option>
              <option value="GET">GET</option>
            </select>
          </div>
          <div class="form-group">
            <label class="control-label">是否废弃</label>
            <select class="col-3 form-control" name="tc_disabled" disabled="disabled">
              <option value="false">false</option>
              <option value="true">true</option>
            </select>
            <label class="control-label">开发者</label>
            <select class="col-3 form-control" name="tc_dev" disabled="disabled" >
              <option value="赵聃">赵聃</option>
              <option value="李德洪">李德洪</option>
              <option value="周欢">周欢</option>
            </select>
          </div>
          <div class="form-group">
            <label class="control-label">请求头header</label>
            <div id="update_jsoneditor_header_" style="width: auto; height: auto;"></div>
          </div>
          <div class="form-group">
            <label class="control-label">请求参数</label>
            <div id="update_jsoneditor_queryParams_" style="width: auto; height: auto;"></div>
          </div>
          <div class="form-group">
            <label class="control-label">返回结果Response</label>
            <div id="update_jsoneditor_response_" style="width: auto; height: auto;"></div>
          </div>
          <!--</li>-->
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" data-backdrop="false" id="btn_edit_tc" ></span>保存</button>
      </div>
    </div>
  </div>
</div>


<!-- 添加用例集合（弹Modal框） -->
<div class="modal fade" id="addTCCollectModal" tabindex="-1" role="dialog" aria-labelledby="addTCCollectModalLabel" aria-hidden="true" style="height:100%;overflow-y: scroll;">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="addTCCollectModalLabel">添加用例集合</h4>
      </div>
      <!--<form id="formModelForCollect" class="form-inline" action="/ShowDoc/addtestcasecollect" method="POST">-->
      <!--</form>-->
      <div class="modal-body">
        <div id="tc_coll_template" uniqid="" class="form-group">
          <div>
            <label class="control-label" style="text-align:right">集合名</label>
            <input name="tc_coll_name" class="form-control" required="required" />
          </div>
          <div>
            <label class="control-label" style="text-align:right">服务器</label>
            <input name="tc_coll_testEnv" class="form-control" required="required" />
          </div>
          <div style="display: none">
            <label class="control-label" style="text-align:right">端口号</label>
            <input name="tc_coll_testEnvPort" class="form-control" required="required" />
          </div>
          <div>
            <label class="control-label" style="text-align:right">选择文档</label>
            <select id="select_tc_coll_docName" name="tc_docName" class="form-control" required="required" />
            <!--<option value="">text</option>-->
            </select>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" data-backdrop="false" id="add_tc_coll_2db">提交</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal -->
</div>

<!-- 左侧栏: 用例集合列表。 -->
  <ul class="nav navbar-nav side-nav">
    <li style="height: 49px">
      <button type="button" class="btn btn-info" data-toggle="modal" data-target="" id="append_tc_coll_ui" style="width: auto;height: auto">添加用例集合</button>
      <button type="button" class="btn btn-info" data-toggle="modal" id="del_all_tc_coll" style="width: auto;height: auto;display: none">删除所有用例集合</button>
    </li>

    <!--<li>-->
      <!--<div class="modal-body">-->
        <!--&lt;!&ndash;<form action='/ShowDoc/operatfile' method="post" id="fileForm" enctype="multipart/form-data">&ndash;&gt;-->
          <!--&lt;!&ndash;<label class="control-label" for="inputSuccess"><font color="#FFFFFF" size="4">导入用例</font></label>&ndash;&gt;-->
          <!--&lt;!&ndash;<input type="file" id="uploadfile" name="submit" accept=".postman_collection" onchange="upfile()">&ndash;&gt;-->
        <!--&lt;!&ndash;</form>&ndash;&gt;-->
      <!--</div>-->
    <!--</li>-->
    <%if(data&&data.length>0) {%>
    <%for(var index=data.length-1;index>0;index--){ var record=data[index];%>
    <li>
      <a href="javascript:void(0)" data-toggle="collapse" data-target="<%='#info' + index%>" style="display:block">
        <i class="fa fa-fw"></i> <%=record.name%><i class="fa fa-fw"></i>
        <!--<i class="fa fa-fw fa-caret-up"></i>-->
        <div>
          <button id="<%='edit_tc_coll_'+index%>" name="query_tc_coll" uniqid="<%=record.uniqID%>" class="fa fa-edit" style="width: auto;height: auto">查看</button>
          <button id="<%='export_tc_coll_'+index%>" name="export" uniqid="<%=record.uniqID%>" class="fa fa-dashboard" style="width: auto;height: auto">导出</button>
        </div>
      </a>
      <ul id="<%='info' + index%>" class="collapse">
        <!--<li>-->
          <!--<%record.ReqItems.forEach(function (caseItem,i) {%>-->
            <!--<a href="javascript:void(0)" id="<%=caseItem.name%>" onclick="requestItem(this)"><%=caseItem.name%></a>-->
          <!--<%})%>-->
        <!--</li>-->
      </ul>
    </li>
    <%}%>
    <%}%>
  </ul>

  <div id="page-wrapper-right" aria-hidden="false" class="right-operation">


    <div class="row">
      <div class="col-lg-12">
        <!-- Page Heading -->
        <h1 class="page-header" id="tc_coll_name" uniqid="<%=curr_tc_coll?curr_tc_coll.uniqID:''%>"><%=curr_tc_coll?curr_tc_coll.name:'默认'%></h1>
        <ol class="breadcrumb">
          <li>
            <i class="fa fa-dashboard"></i>所属文档
            <input id="tc_coll_doc" name="tc_coll_doc" value="<%=curr_tc_coll?curr_tc_coll.docName:'无'%>"
                   uniqid="<%=curr_tc_coll?curr_tc_coll.docUniqID:''%>" disabled="true" style="width:230px; height:auto;"/>
          </li>
          <li>
            <i class="fa fa-dashboard"></i>服务器
            <input id="testEnv" name="testEnv" value="<%=curr_tc_coll?curr_tc_coll.testEnv:'无'%>" style="width:180px; height:auto;" />
          </li>
          <li style="display: none">
            <i class="fa fa-dashboard"></i>端口号
            <input id="testEnvPort" name="testEnvPort" value="<%=curr_tc_coll?curr_tc_coll.testEnvPort:'无'%>" style="width:50px; height:auto;" />
          </li>
          <div style="float:right">
            <div class="btn btn-info" id="add_tc_ui" style="width: auto;height: auto">新增用例</div>
            <div class="btn btn-info" id="update_tc_coll" style="width: auto;height: auto">更新集合</div>
          </div>
        </ol>
      </div>
    </div>
      <!-- /.row -->

      <!-- 接口表格 -->
      <div class="row">
        <div class="col-lg-12">
          <div class="table-responsive">
            <table class="table table-hover">
              <thead>
              <tr>
                <th style="display:none">uniqid</th>
                <th>用例名</th>
                <th>用例描述</th>
                <th>请求URL</th>
                <th style="width:8%">开发者</th>
                <th style="width:12%">操作</th>
              </tr>
              </thead>
              <tbody>
              <%if(curr_tc_coll && curr_tc_coll.ReqItems){
              for(var i=curr_tc_coll.ReqItems.length-1;i>=0;i--){%>
              <tr>
                <td  style="display:none"><%=curr_tc_coll.ReqItems[i].uniqID%></td>
                <td><%=curr_tc_coll.ReqItems[i].name%></td>
                <td><%=curr_tc_coll.ReqItems[i].description%></td>
                <td><%=curr_tc_coll.ReqItems[i].url%></td>
                <td><%=curr_tc_coll.ReqItems[i].dev%></td>
                <td uniqid="<%=curr_tc_coll.ReqItems[i].uniqID%>">
                  <a style="cursor: pointer" name="execTC" uniqid="<%=curr_tc_coll.ReqItems[i].uniqID%>">运行</a>
                  <a style="cursor: pointer" name="editTC" uniqid="<%=curr_tc_coll.ReqItems[i].uniqID%>">修改</a>
                  <a style="cursor: pointer" name="removeTC" uniqid="<%=curr_tc_coll.ReqItems[i].uniqID%>">删除</a>
                </td>
                </td>
              </tr>
              <%}}%>

              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>

  <link href="/xd-autotest-framework/css/jsoneditor.css" rel="stylesheet" type="text/css">
  <script src="/xd-autotest-framework/js/jsoneditor.js"></script>
  <script src="/xd-autotest-framework/js/testcase/testcase.js"></script>

  <script>
    //定义全局变量, 来保存请求头、请求参数、请求response的jsoneditors.
    var global_case_add_header_jsoneditor=null, global_case_add_param_jsoneditor=null,global_case_add_response_jsoneditor=null,
      global_case_update_header_jsoneditor=null,global_case_update_param_jsoneditor=null,global_case_update_response_jsoneditor=null;
    var global_doc_apis=null;
  </script>

